import { _decorator, Component, Node, director } from 'cc'
import { EVENT_ENUM, FADE_STATE_ENUM, SCENE_ENUM } from '../../Enum'
import { FaderManager } from '../../Runtime/FaderManager'
const { ccclass, property } = _decorator

/**
 * Predefined variables
 * Name = StartManager
 * DateTime = Mon Aug 01 2022 17:17:33 GMT+0800 (中国标准时间)
 * Author = Zero_Y
 * FileBasename = StartManager.ts
 * FileBasenameNoExtension = StartManager
 * URL = db://assets/Scripts/Scene/StartManager.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */

@ccclass('StartManager')
export class StartManager extends Component {
  onLoad() {
    director.preloadScene(SCENE_ENUM.Battle)
    FaderManager.Instance.fadeOut(1000)
    this.node.once(Node.EventType.TOUCH_END, this.handleStart, this)
  }

  async handleStart() {
    await FaderManager.Instance.fadeIn(300)
    director.loadScene(SCENE_ENUM.Battle)
  }
}
